<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <title>SpringCloud Demo</title>
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="bootstrap/css/font-awesome.min.css" rel="stylesheet"/>
    <link href="bootstrap/css/style.css" rel="stylesheet"/>
    <link href="bootstrap/css/login.min.css" rel="stylesheet"/>
</head>
<body>
<div class="signinpanel">
    <div class="row">
        <div class="col-sm-7">
            <div class="signin-info">
                <div class="m-b"></div>
                <h4>欢迎使用 <strong>拉钩教育-Spring Cloud Demo</strong></h4>
                <ul class="m-b">
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Spring Cloud Config Bus </li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Spring Cloud Eureka </li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Spring Cloud Feign (Hystrix Ribbon) </li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Spring Cloud Gateway + nginx</li>
                </ul>
            </div>
        </div>
        <div class="col-sm-5">
            <h4 class="no-margins">登录：</h4>
            <input type="text"     name="email" class="form-control uname"     placeholder="邮箱" value=""    />
            <input type="password" name="password" class="form-control pword"     placeholder="密码"   value="" />
            <button class="btn btn-success btn-block" id="btnSubmit">登录</button>
            <a style="width: 100%;text-align: center;" href="register.html" target="_self">新账号注册</a>
        </div>
    </div>
    <div class="signup-footer">
        <div class="pull-left">
            &copy; 2020 All Rights Reserved. Lagou.edu <br>
        </div>
    </div>
</div>

<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $(document).ajaxComplete(function(e, xhr, settings){
            redirectHandle(xhr);
        });

        function redirectHandle(xhr) {
            //获取后台返回的参数
            var url = xhr.getResponseHeader("redirectUrl");
            console.log("redirectUrl = " + url);
            var enable = xhr.getResponseHeader("enableRedirect");
            if((enable == "true") && (url != "")){
                var win = window;
                while(win != win.top){
                    win = win.top;
                }
                win.location.href = url;
            }
        }

        $("#btnSubmit").click(function () {
            var email = $(".uname").val().trim();
            var password = $(".pword").val().trim();
            if (email == ""){
                alert("请输入email");
                return ;
            }
            if (password == ""){
                alert("请输入密码");
                return ;
            }
            $.ajax({
                url:"../api/user/login/"+email+"/"+password,
                type:"GET",
                success:function(result,status,xhr){
                },
                statusCode: {
                    500:function(s) {
                        alert(s.responseText);
                    }
                }
            });
        });
    })
</script>
</body>
</html>